<template>
 <div>
     <headJump title="网易严选"/>
         <!-- 地址栏 -->
    <div class="adress" v-if="isttt">
      <!-- 地址栏 -->
  <van-address-list
  v-model="chosenAddressId"
  :list="list"
  default-tag-text="默认"
  @add="onAdd"
  @edit="onEdit"
  @click-item="gotodo"
/>
    </div>
   <ediTadd v-else/>
    </div>  
</template>

<script>
//默认模拟数据
import { Toast } from 'vant'
import ediTadd from './Edit/index.vue'
export default {
  name:'addRsss',
  components:{
    ediTadd,
  },
  data() {
    return {
      isttt:true,
      chosenAddressId: '1',
      list: [
        {
          id: '1',
          name: '张三',
          tel: '13000000000',
          address: '浙江省杭州市西湖区文三路 138 号东方通信大厦 7 楼 501 室',
          isDefault: false,
        },
      ],

    }  
  },
  mounted() {
    this.$bus.$on('delte',()=>{
      this.isttt = true
    })
  },
  methods: {
    onAdd() {
      Toast('新增地址')
      this.isttt = false
    },
    onEdit(item, index) {
      Toast('编辑地址:' + index)
    },
    gotodo(index){
      index.isDefault=true
      this.list.forEach(element => {
        if(element.id!==index.id){
          element.isDefault = false
        }
      })
    }
  },
}
   

  

</script>

<style lang='less' scoped>
 // 地址栏
  .adress {
    border-bottom: 0.3rem solid #eee;
  }

</style>